<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="949.35">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #0016e6}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #623924; min-height: 16.0px}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}
p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #a32011}
p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco}
p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #606060}
p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #0012b9}
p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #356f15}
span.s1 {font: 18.0px Helvetica}
span.s2 {text-decoration: underline}
span.s3 {color: #000000}
span.s4 {color: #2138d2}
span.s5 {color: #0012b9}
span.s6 {color: #356f15}
span.Apple-tab-span {white-space:pre}
</style>
</head>
<body>
<p class="p1"><span class="s1"><b>SwitchDelay<span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></b></span><b>feedback delay line implementing switch-and-ramp buffer jumping</b></p>
<p class="p2"><br></p>
<p class="p1"><b>SwitchDelay.ar(input, drylevel, wetlevel, delaytime, delayfactor, maxdelaytime, mul, add)</b></p>
<p class="p2"><br></p>
<p class="p1">A feedback delay line which allows moving the buffer read position using the switch-and-ramp technique</p>
<p class="p1">as described by Miller S. Puckette in his Theory and Techniques of Electronic Music book.</p>
<p class="p3"><span class="s2"><a href="http://crca.ucsd.edu/~msp/techniques/latest/book.pdf">http://crca.ucsd.edu/~msp/techniques/latest/book.pdf</a></span><span class="s3"> (chapter 4)</span></p>
<p class="p2"><br></p>
<p class="p1">Altering the buffer read position, in order to affect the perceived delay speed/timing, creates a<span class="Apple-converted-space"> </span></p>
<p class="p1">discontinuity in the signal, typically causing unwanted audible artefacts. The switch-and-ramp technique seeks to neutralise these artefacts and allow switching with minimal clicks. See examples.</p>
<p class="p2"><br></p>
<p class="p1"><b>input</b> - a signal to be filtered</p>
<p class="p1"><b>drylevel</b> - level of dry signal (default: 1.0)</p>
<p class="p1"><b>wetlevel</b> - level of delayed signal (default: 1.0)</p>
<p class="p1"><b>delaytime</b> - seconds to delay signal (default: 1.0)</p>
<p class="p1"><b>delayfactor</b> - multiplier for feedback level, affects the length of the feedback tail (default 0.7)</p>
<p class="p1"><span class="Apple-converted-space">   <span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>limited slightly below 1.0 to avoid speaker damaging mistakes</p>
<p class="p1"><b>maxdelaytime</b> - buffer size (default 20.0)</p>
<p class="p2"><br></p>
<p class="p1"><b><span class="Apple-converted-space">  </span>See also:</b> <a href="../../../../Applications/SuperCollider3/build/Help/UGens/Delays/CombN.html"><span class="s4">CombN</span></a><span class="s4"> </span>etc</p>
<p class="p4"><br></p>
<p class="p5"><br></p>
<p class="p6">// before anything else</p>
<p class="p7">s = <span class="s5">Server</span>.local.boot;</p>
<p class="p8"><span class="s3">b = </span><span class="s5">Buffer</span><span class="s3">.read(s, </span>"sounds/a11wlk01.wav"<span class="s3">);</span></p>
<p class="p5"><br></p>
<p class="p6">// simple feedback delay</p>
<p class="p7">(</p>
<p class="p7"><span class="s5">SynthDef</span>(<span class="s6">'help-switchdelay-1'</span>, { <span class="s5">arg</span> out=0, bufnum;</p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="s5">Out</span>.ar(out,</p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>Pan2.ar(</p>
<p class="p9"><span class="s3"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>SwitchDelay<span class="s3">.ar(</span></p>
<p class="p7"><span class="s5"><span class="Apple-tab-span">	</span></span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s5">PlayBuf</span>.ar(numChannels: 1, bufnum: bufnum, loop: 0) * 0.5,</p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>delaytime: 0.4,</p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>delayfactor: 0.6,</p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>wetlevel: 0.7</p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>)</p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>)</p>
<p class="p7"><span class="Apple-tab-span">	</span>);</p>
<p class="p7">}).send(s);</p>
<p class="p7">)</p>
<p class="p5"><br></p>
<p class="p10"><span class="s3">x = </span><span class="s5">Synth</span><span class="s3">(</span>'help-switchdelay-1'<span class="s3">, [</span>\bufnum<span class="s3">, b]);</span></p>
<p class="p7">x.free;</p>
<p class="p5"><br></p>
<p class="p5"><br></p>
<p class="p6">// this time, change the buffer read pointer periodically.</p>
<p class="p7">(</p>
<p class="p7"><span class="s5">SynthDef</span>(<span class="s6">'help-switchdelay-2'</span>, { <span class="s5">arg</span> out=0, bufnum, delaytime;</p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="s5">Out</span>.ar(out,</p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>Pan2.ar(</p>
<p class="p9"><span class="s3"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>SwitchDelay<span class="s3">.ar(</span></p>
<p class="p7"><span class="s5"><span class="Apple-tab-span">	</span></span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s5">PlayBuf</span>.ar(numChannels: 1, bufnum: bufnum, loop: 0) * 0.5,</p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>wetlevel: 0.6,</p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>delaytime: <span class="s5">Select</span>.kr(</p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s5">Stepper</span>.kr(<span class="s5">Impulse</span>.kr(0.5), 0, 0, 3),</p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>#[ 0.02, 0.1, 0.725, 0.25 ]<span class="Apple-converted-space"> </span></p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>)</p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>)</p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>)</p>
<p class="p7"><span class="Apple-tab-span">	</span>);</p>
<p class="p7">}).send(s);</p>
<p class="p7">)</p>
<p class="p5"><br></p>
<p class="p10"><span class="s3">x = </span><span class="s5">Synth</span><span class="s3">(</span>'help-switchdelay-2'<span class="s3">, [</span>\bufnum<span class="s3">, b, </span>\loop<span class="s3">, 0, </span>\delaytime<span class="s3">, 2.0]);</span></p>
<p class="p7">x.free;</p>
<p class="p5"><br></p>
</body>
</html>
